import tenantapi from '@/api/declaration/tenantApi'
import httpRequest from '@/config/axios/httpRequest'
import {
  CreateTenantReq,
  CreateTenantResp,
  DeleteTenantReq,
  DeleteTenantResp,
  ExportTenantReq,
  QueryTenantByIdReq,
  QueryTenantByIdResp,
  QueryTenantByPageReq,
  QueryTenantByPageResp,
  UpdateTenantReq,
  UpdateTenantResp
} from '@/models/tenant/TenantModel'
// 查询租户列表
export const getTenantPage = async (params: QueryTenantByPageReq) => {
  return await httpRequest.get<QueryTenantByPageResp>(tenantapi.QueryTenantByPage, { params })
}

// 查询租户详情
export const getTenant = async (params: QueryTenantByIdReq) => {
  return await httpRequest.get<QueryTenantByIdResp>(tenantapi.QueryTenantDetail, { params })
}

// 新增租户
export const createTenant = async (data: CreateTenantReq) => {
  return await httpRequest.post<CreateTenantResp>(tenantapi.CreateTenant, data)
}

// 修改租户
export const updateTenant = async (data: UpdateTenantReq) => {
  return await httpRequest.put<UpdateTenantResp>(tenantapi.UpdateTenant, data)
}

// 删除租户
export const deleteTenant = async (params: DeleteTenantReq) => {
  return await httpRequest.delete<DeleteTenantResp>(tenantapi.DeleteTenant, { params })
}

// 导出租户
export const exportTenant = async (params: ExportTenantReq) => {
  return await httpRequest.download(tenantapi.ExportTenant, { params, responseType: 'blob' })
}
